package com.jspica.app.messagespam;

import java.text.*;
import java.util.*;

import android.content.Context;
import android.database.Cursor;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

import com.jspica.app.messagespam.R;

/**
 * 디비에서 조회한 사용 목록을 목록View에 뿌려주기 위한 포맷팅을 한다.
 * 
 * @author nozisim
 * 
 */
public class MyCursorAdapter extends SimpleCursorAdapter {

	private final long totalSpent = 0;

	public MyCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
		super(context, layout, c, from, to);
	
	}

	
	@Override
	public void setViewText(TextView tv, String str) {
		Date date = null;
		
		if (tv.getId() == R.id.time) {
			try {
				date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(str);
			} catch (ParseException e) {
				e.printStackTrace();
			}
			tv.setText("(" + new SimpleDateFormat("MM-dd HH:mm").format(date) + ")");
		} else  if (tv.getId() == R.id._id) {
			tv.setText(str + "");
		} else {
			tv.setText(str);
		}
	}

	public long getTotalSpent() {
		return totalSpent;
	}

	
}